package com.zzyl.nursing.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

@Data
public class DeviceDataQueryDTO {
    private String iotId;
    private String functionId;
    private Long startTime;
    private Long endTime;

    // 转换为 LocalDateTime 的方法
    public LocalDateTime getStartDateTime() {
        return startTime != null ?
                LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneId.systemDefault()) : null;
    }

    public LocalDateTime getEndDateTime() {
        return endTime != null ?
                LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneId.systemDefault()) : null;
    }
}